package xls;

import com.extentech.ExtenXLS.CellHandle;
import com.extentech.ExtenXLS.WorkBookHandle;
import com.extentech.ExtenXLS.WorkSheetHandle;
import com.extentech.formats.XLS.WorkSheetNotFoundException;

public class ReadExcel {

	private WorkBookHandle workBook;

	public ReadExcel() {

	}

	public ReadExcel(String finpath) {
		WorkBookHandle workBook = new WorkBookHandle(finpath);
		this.workBook = workBook;
	}
	
	public WorkBookHandle getWorkBookHandle() {
		return workBook;
	}
	
	public WorkSheetHandle getSheet(int num) throws WorkSheetNotFoundException{
		return workBook.getWorkSheet(num);
	}
	


	
	

	public static void main(String[] args) {
		// String finpath =
		// "/home/noel/Dropbox/uni/ss14/swp/bspDOC/Aufgabenverzeichnis-KI.xlsx";
		String finpath = "C:/Users/nnn/Dropbox/uni/ss14/swp/bspDOC/Aufgabenverzeichnis-KI.xlsx";
		ReadExcel excel = new ReadExcel(finpath);

		// Get first sheet
		WorkSheetHandle sheet = null;

		try {
			sheet = excel.getSheet(0);
		} catch (WorkSheetNotFoundException e) {
			e.printStackTrace();
		}


		for (CellHandle cell : sheet.getCells()) {
			if (cell.getRowNum() == 2)
				System.out
						.println(cell.getStringVal());

		}

		System.out.println(sheet.getSheetName());
		System.out.println(sheet.getRows()[2].getCells()[0].getStringVal());

	}

}
